#include <iostream>
#include <string>

using namespace std;

int number_column(string s);

int main() {
	string excel_column;
	getline(cin, excel_column);
	cout << number_column(excel_column) << endl;
}

int number_column(string s) {
	int sum = 0;
	for (unsigned int i = 0; i < s.length(); i++) {
		sum *= 26;
		sum += s[i] - 'A' + 1;
	}
	return sum;
}